package com.wanxin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wanxin.mapper.UserMapper;
import com.wanxin.pojo.User;
import com.wanxin.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author common
 */
@Service("UserService")
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    /**
     * 用户Mapper
     */
    @Autowired
    private UserMapper userMapper;

    /**
     * 用户登入
     * @param uname 用户身份
     * @return 用户信息
     */
    @Override
    public User selectInfoUserService(String uname) {
        return userMapper.selectOne(new QueryWrapper<User>().eq("uname", uname));
    }

    /**
     * 获取当前用户的权限信息
     * @param uname 用户身份
     * @return 用户信息
     */
    @Override
    public List<String> selectProwerUserService(String uname) {
        return userMapper.selectOnePrower(uname);
    }

    /**
     * 获取当前用户的角色信息
     * @param uname 用户身份
     * @return 用户信息
     */
    @Override
    public List<String> selectRoleUserService(String uname) {
        return userMapper.selectOneRole(uname);
    }
}
